package com.seocoo.worker.order;

import android.graphics.Color;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.TextView;

import com.seocoo.worker.R;
import com.sfh.lib.ui.MVVMFragment;

/**
 * author : Ssp
 * date   : 2020/2/23 16:25
 * desc   : 维修订单主列表
 */
public class OrderStarMaintainParentFragment1 extends MVVMFragment implements View.OnClickListener {

    private TextView tv_take1;
    private TextView tv_take2;
    private FragmentManager childFragmentManager;
    private FragmentTransaction transaction;
    private OrderStarMaintainParentFragment2 fragment2;
    private OrderStarMaintainParentFragment fragment;

    @Override
    public int getLayout() {
        return R.layout.order_maintain_parent_fragment1;
    }

    @Override
    public void initData(View view) {
        childFragmentManager = getChildFragmentManager();
        transaction = childFragmentManager.beginTransaction();
        fragment = new OrderStarMaintainParentFragment();
        fragment2 = new OrderStarMaintainParentFragment2();
        transaction.add(R.id.fl_content, fragment).show(fragment);
        transaction.add(R.id.fl_content, fragment2).hide(fragment2);
        transaction.commit();
        tv_take1 = view.findViewById(R.id.tv_take1);
        tv_take2 = view.findViewById(R.id.tv_take2);
        tv_take1.setOnClickListener(this);
        tv_take2.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        transaction = childFragmentManager.beginTransaction();
        switch (v.getId()) {
            case R.id.tv_take1:
                //我要接单
                tv_take1.setBackgroundResource(R.drawable.base_file_btn_conner5_green);
                tv_take1.setTextColor(Color.parseColor("#ffffff"));
                tv_take2.setBackgroundResource(R.drawable.base_file_btn_stroke5_green);
                tv_take2.setTextColor(Color.parseColor("#019752"));
                transaction.hide(fragment2).show(fragment);
                transaction.commit();
                break;
            case R.id.tv_take2:
                //平台指派
                tv_take2.setBackgroundResource(R.drawable.base_file_btn_conner5_green);
                tv_take2.setTextColor(Color.parseColor("#ffffff"));
                tv_take1.setBackgroundResource(R.drawable.base_file_btn_stroke5_green);
                tv_take1.setTextColor(Color.parseColor("#019752"));
                transaction.hide(fragment).show(fragment2);
                transaction.commit();
                break;
            default:
                break;
        }
    }
}
